#CROSS_COMPILE = arm-linux-
CROSS_COMPILE = 
AS		= $(CROSS_COMPILE)as
LD		= $(CROSS_COMPILE)ld
CC		= $(CROSS_COMPILE)gcc
CPP		= $(CC) -E
AR		= $(CROSS_COMPILE)ar
NM		= $(CROSS_COMPILE)nm

STRIP		= $(CROSS_COMPILE)strip
OBJCOPY		= $(CROSS_COMPILE)objcopy
OBJDUMP		= $(CROSS_COMPILE)objdump

export AS LD CC CPP AR NM
export STRIP OBJCOPY OBJDUMP

TARGET := test_init_attr

CFLAGS := -Wall -O2 -g
CFLAGS += -I $(shell pwd)/include
# CFLAGS += -std=c99

LDFLAGS := -lpthread
LDFLAGS += -T$(shell pwd)/ldscript.lds
LDFLAGS		+= -Wl,-Map=$(TARGET).map -Wl,--cref


export CFLAGS LDFLAGS

TOPDIR := $(shell pwd)
export TOPDIR



obj-y += main.o
obj-y += init.o
# obj-y += add/
# obj-y += sub/
# obj-y += input/

# Be silent per default, but 'make V=1' will show all compiler calls.
ifneq ($(V), 1)
Q := @
# Do not print "Entering directory ..."
MAKEFLAGS += --no-print-directory
endif

export Q

all : 
	$(Q)$(MAKE) -C ./ -f $(TOPDIR)/Makefile.build
	@printf "Generate $(TARGET)\n"
	$(Q)$(CC) -static $(LDFLAGS) -o $(TARGET) built-in.o


clean:
	rm -f $(shell find -name "*.o")
	rm -f $(TARGET)

distclean:
	rm -f $(shell find -name "*.o")
	rm -f $(shell find -name "*.d")
	rm -f $(TARGET)
	rm -f tags *.tag* *.out
					
